using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;


namespace ChuyenDongVatLy
{
   
    public class ChuyenDongThang : Microsoft.Xna.Framework.GameComponent
    {
        BaseObject _object;
        Game1 game;
        Vector2 _S0 = new Vector2(10, 0);

        public Vector2 S0
        {
            get { return _S0; }
            set { _S0 = value; }
        }

        public ChuyenDongThang(Game1 game1)
            : base(game1)
        {
            // TODO: Construct any child components here
            this.game = game1;
            _object = new BaseObject();
            _object.Pos = new Vector2(400, 100);
                     
        }  
        public ChuyenDongThang(Game1 game1,float vantocbandau, float giatoc,Vector2 vitribandau):base(game1)
        {
            this.game = game1;
            _object = new BaseObject();
            _object.A = giatoc;
            _object.V0 = vantocbandau;
            this._S0 = vitribandau;
        }
        public override void Initialize()
        {
            // TODO: Add your initialization code here
            base.Initialize();
        }

        public void LoadContent(ContentManager Content)
        {
           _object.Picture= Content.Load<Texture2D>("ball");
        }
        public override void Update(GameTime gameTime)
        {
            // TODO: Add your update code here
            ChuyenDong(gameTime);
            base.Update(gameTime);
        }
        public void ChuyenDong(GameTime gameTime)
        {

            TimeGame._gameTime += ((float)gameTime.ElapsedGameTime.Milliseconds / 1000);                                   
                    _object.Pos = _S0+ new Vector2((float)(_object.V0 *  TimeGame._gameTime + 0.5 * _object.A *  TimeGame._gameTime *  TimeGame._gameTime), 0);                    
                       
        }
        public void Draw(SpriteBatch sp)
        {
            sp.Draw(_object.Picture, new Rectangle((int)_object.Pos.X, (int)_object.Pos.Y, 60, 60), Color.White);
        }
    }
}
